﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;

namespace StyleMVVM.View.Impl
{
	public class BorderAdorner : Adorner
	{
		private Border border = null;

		public BorderAdorner(UIElement adornedElement, Color borderColor)
			: base(adornedElement)
		{
			border = new Border
				         {
					         BorderThickness = new Thickness(3),
					         BorderBrush = new SolidColorBrush(borderColor),
					         CornerRadius = new CornerRadius(3)
				         };
		}

		public bool IsWarning { get; set; }

		protected override Visual GetVisualChild(int index)
		{
			return border;
		}

		protected override int VisualChildrenCount
		{
			get { return 1; }
		}

		protected override Size ArrangeOverride(Size finalSize)
		{
			border.Arrange(new Rect(-3, -3, finalSize.Width + 6, finalSize.Height + 6));

			return finalSize;
		}
	}
}